/**
    Copyright (C) 2011  Alexander Vollmer

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jefb.web.util;

import org.zkoss.util.resource.Labels;
import org.zkoss.zul.Messagebox;

public class ZKUtils {
	
	private ZKUtils(){}
	
	public static String getLabel(String key){
		return Labels.getLabel(key);
	}
	
	public static String getLabel(String key, String... args){
		return Labels.getLabel(key, args);
	}
	
	public static void showInfo(String textKey){
		try {
			Messagebox.show(getLabel(textKey), "Info",  
			        Messagebox.OK, Messagebox.INFORMATION);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void showWarning(String textKey){
		try {
			String label = getLabel(textKey);
			if(label!=null){
				Messagebox.show(textKey, "Warning",  
			        Messagebox.OK, Messagebox.EXCLAMATION);
			}else{
				Messagebox.show(getLabel(textKey), "Warning",  
				        Messagebox.OK, Messagebox.EXCLAMATION);
			}
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			// TODO log exception
			e.printStackTrace();
		} 
	}
	
	public static void showWarning(String promptKey, String msgKey){
		try {
			Messagebox.show(getLabel(msgKey), getLabel(promptKey),  
			        Messagebox.OK, Messagebox.EXCLAMATION);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			// TODO log exception
			e.printStackTrace();
		} 
	}
}
